﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bymed.SpineScan.Repository.EntityFramework;
using Bymed.SpineScan.Repository.Interface;
using Bymed.SpineScan.Service.Interface;

namespace Bymed.SpineScan.Service
{
    /// <summary>
    /// A factory class that manage every single service.
    /// </summary>
    public class ServiceFactory : IServiceFactory
    {
        protected IRepositoryFactory RepositoryFactory;

        /// <summary>
        /// The basic version of Dependency Injection.
        /// </summary>
        /// <param name="repositoryFactory">An instance implements IRepositoryFactory.</param>
        public ServiceFactory(IRepositoryFactory repositoryFactory)
        {
            RepositoryFactory = repositoryFactory;
        }

        public ServiceFactory() : this(new RepositoryFactory()) { }

        /// <summary>
        ///  Create an instance of TestResultService to do any related business logic.
        /// </summary>
        /// <returns>The instance that implements ITestResultService.</returns>
        public ITestResultService CreateTestResultService()
        {
            return new TestResultService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of TestTrackingService to do any related business logic.
        /// </summary>
        /// <returns>The instance that implements ITestTrackingService.</returns>
        public ITestTrackingService CreateTestTrackingService()
        {
            return new TestTrackingService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of IPatientService to do any related business logic.
        /// </summary>
        /// <returns>The instance that implements IPatientService.</returns>
        public IPatientService CreatePatientService()
        {
            return new PatientService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of IDiagnosticMessageReferenceService to do any related business logic.
        /// </summary>
        /// <returns>The instance that implements IDiagnosticMessageReferenceService.</returns>
        public IDiagnosticMessageReferenceService CreateDiagnosticMessageReferenceService()
        {
            return new DiagnosticMessageReferenceService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of ITestResultDiagnosticMessageService to do any related business logic.
        /// </summary>
        /// <returns>The instance that implements ITestResultDiagnosticMessageService.</returns>
        public ITestResultDiagnosticMessageService CreateTestResultDiagnosticMessageService()
        {
            return new TestResultDiagnosticMessageService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of AttendingDoctorService to do any related business logic.
        /// </summary>
        /// <returns>The instance that implements IAttendingDoctorService.</returns>
        public IAttendingDoctorService CreateAttendingDoctorService()
        {
            return new AttendingDoctorService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of CustomizedTestItemService to do any related business logic.
        /// </summary>
        /// <returns>The instance of CustomizedTestItemService.</returns>
        public ICustomizedTestItemService CreateCustomizedTestItemService()
        {
            return new CustomizedTestItemService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of DataSourceManagementService to do any related business logic.
        /// </summary>
        /// <returns>The instance of DataSourceManagementService.</returns>
        public DataSourceManagementService CreateDataSourceManagementService()
        {
            return new DataSourceManagementService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of BasicConfigurationService to do any related business logic.
        /// </summary>
        /// <returns>The instance of BasicConfigurationService.</returns>
        public BasicConfigurationService CreateBasicConfigurationService()
        {
            return new BasicConfigurationService();
        }

        /// <summary>
        ///  Create an instance of DeviceConfigurationService to do any related business logic.
        /// </summary>
        /// <returns>The instance of DeviceConfigurationService.</returns>
        public DeviceConfigurationService CreateDeviceConfigurationService()
        {
            return new DeviceConfigurationService();
        }

        /// <summary>
        ///  Create an instance of GenuineCheckService to do any related business logic.
        /// </summary>
        /// <returns>The instance of GenuineCheckService.</returns>
        public GenuineCheckService CreateGenuineCheckService()
        {
            return new GenuineCheckService();
        }
    }
}
